package easy;

import java.util.ArrayList;
import java.util.List;

/**
 * @author admin
 * 412. Fizz Buzz
 * 解题思路：定义两个布尔值，一个用来判断是否被3整除，一个用来判断是
 * 否被5整除。for循环n次，模拟是否满足添加，分别往list添加对应的值
 */
public class LeeCode412 {

    public List<String> fizzBuzz(int n) {

        List<String> list = new ArrayList<>();

        for (int i = 1; i <= n; i++) {

            boolean divBy3 = (i % 3 == 0);
            boolean divBy5 = (i % 5 == 0);

            if (divBy3 && divBy5){
                list.add("FizzBuzz");
            }else if (divBy3){
                list.add("Fizz");
            }else if (divBy5){
                list.add("Buzz");
            }else {
                list.add(Integer.toString(i));
            }
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(new LeeCode412().fizzBuzz(15));
    }
}
